package com.example.demo.web;

import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.demo.conf.AutoConfiguration;
import com.example.demo.conf.TestConfiguration;


@RestController
public class TestController {

	@Autowired
	private AutoConfiguration ac;
	@Autowired
	private TestConfiguration tc;
	
	@GetMapping("/test")
	public String helloworld(){
		return "driverClassName1====="+ac.getDriverClassName()+"   userName:"+tc.getUserName();
	}
	
	@GetMapping("/helloworld2")
	public String helloworld2(){
		return "helloworld2";
	}
	
	@RequestMapping(value="/getJson",headers="Accept=text/plain")
	public String getJsonTest() throws JSONException {
		JSONObject json=new JSONObject();
		json.put("msg", "测试");
		json.put("code", 200);
		
		return json.toString();
	}
}